package com.dycx.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Abel
 * <b>商家状态</b>
 * @version 1.0
 */
@Getter
@AllArgsConstructor
public enum SellerStatusEnum {
    /**
     * 审核中
     */
    SELLER_CHECK_STATUS_ING(0, "审核中", "warning"),

    /**
     * 通过
     */
    SELLER_CHECK_STATUS_SUCCESS(1, "通过", "success"),

    /**
     * 拒绝
     */
    SELLER_CHECK_STATUS_REJECT(2, "拒绝", "danger");


    private final Integer code;
    private final String name;
    private final String style;

    public static SellerStatusEnum getCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (SellerStatusEnum supplementTypeEnum : SellerStatusEnum.values()) {
            if (supplementTypeEnum.getCode().equals(code)) {
                return supplementTypeEnum;
            }
        }
        return null;
    }


    /**
     * 转为数据
     *
     * @return 枚举对象数组
     */
    public static List<Map<String, Object>> getList() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (SellerStatusEnum item : SellerStatusEnum.values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("code", item.getCode().toString());
            map.put("name", item.getName());
            map.put("style", item.getStyle());
            list.add(map);
        }
        return list;
    }

}
